package com.bh.web.controller.fee;

import com.bh.common.annotation.Log;
import com.bh.common.core.controller.BaseController;
import com.bh.common.core.domain.AjaxResult;
import com.bh.common.core.page.TableDataInfo;
import com.bh.common.enums.BusinessType;
import com.bh.common.utils.poi.ExcelUtil;
import com.bh.fee.domain.JcFeeType;
import com.bh.fee.service.IJcFeeTypeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 费用类型Controller
 * 
 * @author slx
 * @date 2023-08-19
 */
@RestController
@RequestMapping("/fee/feeType")
public class JcFeeTypeController extends BaseController
{
    @Autowired
    private IJcFeeTypeService jcFeeTypeService;

    /**
     * 查询费用类型列表
     */
    @ApiOperation("查询费用类型列表")
    @PreAuthorize("@ss.hasPermi('fee:feeType:list')")
    @GetMapping("/list")
    public TableDataInfo list(JcFeeType jcFeeType)
    {
        startPage();
        List<JcFeeType> list = jcFeeTypeService.selectJcFeeTypeList(jcFeeType);
        return getDataTable(list);
    }

    /**
     * 查询费用类型列表
     */
    @ApiOperation("查询费用类型列表")
    @GetMapping("/listFeeTypeOption/{type}")
    public AjaxResult listFeeTypeOption(@PathVariable String type)
    {
        List<JcFeeType> list = jcFeeTypeService.listOption(type);
        return AjaxResult.success(list);
    }


    /**
     * 查询自己部门所属的费用类型列表
     */
    @ApiOperation("查询费用类型列表")
    @GetMapping("/listModelFeeTypeOption/{type}")
    public AjaxResult listModelFeeTypeOption(@PathVariable String type)
    {
        List<JcFeeType> list = jcFeeTypeService.listModelOption(type);
        return AjaxResult.success(list);
    }




    /**
     * 导出费用类型列表
     */
    @PreAuthorize("@ss.hasPermi('fee:feeType:export')")
    @Log(title = "费用类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JcFeeType jcFeeType)
    {
        List<JcFeeType> list = jcFeeTypeService.selectJcFeeTypeList(jcFeeType);
        ExcelUtil<JcFeeType> util = new ExcelUtil<JcFeeType>(JcFeeType.class);
        util.exportExcel(response, list, "费用类型数据");
    }

    /**
     * 获取费用类型详细信息
     */
    @ApiOperation("获取费用类型详细信息")
    @PreAuthorize("@ss.hasPermi('fee:feeType:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jcFeeTypeService.selectJcFeeTypeById(id));
    }

    /**
     * 新增费用类型
     */
    @ApiOperation("新增费用类型")
    @PreAuthorize("@ss.hasPermi('fee:feeType:add')")
    @Log(title = "费用类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JcFeeType jcFeeType)
    {
        return toAjax(jcFeeTypeService.insertJcFeeType(jcFeeType));
    }

    /**
     * 修改费用类型
     */
    @ApiOperation("修改费用类型")
    @PreAuthorize("@ss.hasPermi('fee:feeType:edit')")
    @Log(title = "费用类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JcFeeType jcFeeType)
    {
        return toAjax(jcFeeTypeService.updateJcFeeType(jcFeeType));
    }

    /**
     * 删除费用类型
     */
    @ApiOperation("删除费用类型")
    @PreAuthorize("@ss.hasPermi('fee:feeType:remove')")
    @Log(title = "费用类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jcFeeTypeService.deleteJcFeeTypeByIds(ids));
    }
}
